@echo off

if "%1" == "" goto syntax_error
if "%2" == "" goto syntax_error
if "%3" == "" goto syntax_error
if "%4" == "" goto syntax_error

set TOOL_DBSERVER=%1
set TOOL_DBNAME=%2
set TOOL_DBACCOUNT=%3
set TOOL_DBPASSWORD=%4
set TOOL_DBJOBSDIR=Job

@echo Create jobs....

@echo NotifyAdministratorOfIndividualBooking
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBJOBSDIR%\dbo.NotifyAdministratorOfIndividualBooking.Job.sql
if errorlevel 1 goto sql_error

@echo RemindCoupleOfImpedimentDoc
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBJOBSDIR%\dbo.RemindCoupleOfImpedimentDoc.Job.sql
if errorlevel 1 goto sql_error

@echo RemindMinisterOfOrdinaryService
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBJOBSDIR%\dbo.RemindMinisterOfOrdinaryService.Job.sql
if errorlevel 1 goto sql_error

@echo RemoveBookingWithMissingImpedimentDoc
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBJOBSDIR%\dbo.RemoveBookingWithMissingImpedimentDoc.Job.sql
if errorlevel 1 goto sql_error


@echo *************************************************************
@echo *
@echo * All jobs created successfully.
@echo *
@echo *************************************************************
goto end


:syntax_error
@echo *************************************************************
@echo *
@echo * Syntax error!
@echo * Required parameter is missing.
@echo *
@echo * Usage: CreateJobs 'DatabaseServerName' DatabaseName' 'Account' 'Password'
@echo *
@echo *************************************************************
goto end


:sql_error
:end
